<include file="public@header"/>
</head>
<body>
<div class="js-check-wrap">
    <form method="post" class="layui-form js-ajax-form" action="{:url('AdminCategory/listorders')}">
        <table class="layui-table" id="menus-table" lay-even lay-skin="nob" lay-size="lg">
            <thead>
            <tr>
                <th width="16">
                    <input lay-skin="primary" lay-filter="js-check-all" type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                </th>
                <th width="50">ID</th>
                <th>分类名称</th>
            </tr>
            </thead>
            <tbody>
            {$categories_tree}
            </tbody>
        </table>
    </form>
</div>
<include file="public@script"/>
<script>
    $('.data-item-tr').click(function (e) {

        console.log(e);
        var $input = $this.find('input');
        if ($input.is(':checked')) {
            $input.prop('checked', false);
        } else {
            $input.prop('checked', true);
        }
    });

    function confirm() {
        var selectedCategoriesId   = [];
        var selectedCategoriesName = [];
        var selectedCategories     = [];
        $('.js-check:checked').each(function () {
            var $this = $(this);
            selectedCategoriesId.push($this.val());
            selectedCategoriesName.push($this.data('name'));

            selectedCategories.push({
                id: $this.val(),
                name: $this.data('name')
            });
        });

        return {
            selectedCategories: selectedCategories,
            selectedCategoriesId: selectedCategoriesId,
            selectedCategoriesName: selectedCategoriesName
        };
    }
</script>
</body>
</html>